/**
 * 
 */
package be.bejug.scrumadmin;

import java.util.HashSet;
import java.util.Set;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import be.bejug.scrumadmin.domain.Sprint;
import be.bejug.scrumadmin.domain.Story;
import be.bejug.scrumadmin.domain.User;

/**
 * @author Glenn Dejaeger
 * 
 */
@Component
@Scope(value = "singleton")
public class KnowledgeCenter {
	private Set<Story> storiesOfSprint1;
	private Set<Story> storiesOfSprint2;
	private Set<Story> storiesOfSprint3;
	private Set<Story> storiesOfSprint4;
	private Set<Story> storiesOfSprint5;
	private Set<Story> storiesOfSprint6;
	private Set<Sprint> sprints;
	private Sprint sprint1;
	private Sprint sprint2;
	private Sprint sprint3;
	private Sprint sprint4;
	private Sprint sprint5;
	private Sprint sprint6;

	/**
	 * 
	 */
	public KnowledgeCenter() {
		storiesOfSprint1 = new HashSet<Story>();
		Story story1 = ObjectFactory.getStory1();
		Story story2 = ObjectFactory.getStory2();
		Story story3 = ObjectFactory.getStory3();
		story1.addTasks(ObjectFactory.getTask1_1(), ObjectFactory.getTask1_2(),
				ObjectFactory.getTask1_3());
		story2.addTasks(ObjectFactory.getTask2_1(), ObjectFactory.getTask2_2(),
				ObjectFactory.getTask2_3());
		story3.addTasks(ObjectFactory.getTask3_1(), ObjectFactory.getTask3_2(),
				ObjectFactory.getTask3_3());
		storiesOfSprint1.add(story1);
		storiesOfSprint1.add(story2);
		storiesOfSprint1.add(story3);

		storiesOfSprint2 = new HashSet<Story>();
		Story story4 = ObjectFactory.getStory4();
		Story story5 = ObjectFactory.getStory5();
		Story story6 = ObjectFactory.getStory6();
		story4.addTasks(ObjectFactory.getTask4_1(), ObjectFactory.getTask4_2(),
				ObjectFactory.getTask4_3());
		story5.addTasks(ObjectFactory.getTask5_1(), ObjectFactory.getTask5_2(),
				ObjectFactory.getTask5_3());
		story6.addTasks(ObjectFactory.getTask6_1(), ObjectFactory.getTask6_2(),
				ObjectFactory.getTask6_3());
		storiesOfSprint2.add(story4);
		storiesOfSprint2.add(story5);
		storiesOfSprint2.add(story6);

		storiesOfSprint3 = new HashSet<Story>();
		Story story7 = ObjectFactory.getStory7();
		Story story8 = ObjectFactory.getStory8();
		Story story9 = ObjectFactory.getStory9();
		story7.addTasks(ObjectFactory.getTask7_1(), ObjectFactory.getTask7_2(),
				ObjectFactory.getTask7_3());
		story8.addTasks(ObjectFactory.getTask8_1(), ObjectFactory.getTask8_2(),
				ObjectFactory.getTask8_3());
		story9.addTasks(ObjectFactory.getTask9_1(), ObjectFactory.getTask9_2(),
				ObjectFactory.getTask9_3());
		storiesOfSprint3.add(story7);
		storiesOfSprint3.add(story8);
		storiesOfSprint3.add(story9);

		storiesOfSprint4 = new HashSet<Story>();
		Story story10 = ObjectFactory.getStory10();
		Story story11 = ObjectFactory.getStory11();
		Story story12 = ObjectFactory.getStory12();
		story10.addTasks(ObjectFactory.getTask10_1(),
				ObjectFactory.getTask10_2(), ObjectFactory.getTask10_3());
		story11.addTasks(ObjectFactory.getTask11_1(),
				ObjectFactory.getTask11_2(), ObjectFactory.getTask11_3());
		story12.addTasks(ObjectFactory.getTask12_1(),
				ObjectFactory.getTask12_2(), ObjectFactory.getTask12_3());
		storiesOfSprint4.add(story10);
		storiesOfSprint4.add(story11);
		storiesOfSprint4.add(story12);

		storiesOfSprint5 = new HashSet<Story>();
		Story story13 = ObjectFactory.getStory13();
		Story story14 = ObjectFactory.getStory14();
		Story story15 = ObjectFactory.getStory15();
		story13.addTasks(ObjectFactory.getTask13_1(),
				ObjectFactory.getTask13_2(), ObjectFactory.getTask13_3());
		story14.addTasks(ObjectFactory.getTask14_1(),
				ObjectFactory.getTask14_2(), ObjectFactory.getTask2_3());
		story15.addTasks(ObjectFactory.getTask15_1(),
				ObjectFactory.getTask15_2(), ObjectFactory.getTask15_3());
		storiesOfSprint5.add(story13);
		storiesOfSprint5.add(story14);
		storiesOfSprint5.add(story15);

		storiesOfSprint6 = new HashSet<Story>();
		Story story16 = ObjectFactory.getStory16();
		Story story17 = ObjectFactory.getStory17();
		Story story18 = ObjectFactory.getStory18();
		story16.addTasks(ObjectFactory.getTask16_1(),
				ObjectFactory.getTask16_2(), ObjectFactory.getTask16_3());
		story17.addTasks(ObjectFactory.getTask17_1(),
				ObjectFactory.getTask17_2(), ObjectFactory.getTask17_3());
		story18.addTasks(ObjectFactory.getTask18_1(),
				ObjectFactory.getTask18_2(), ObjectFactory.getTask18_3());
		storiesOfSprint6.add(story16);
		storiesOfSprint6.add(story17);
		storiesOfSprint6.add(story18);

		sprints = new HashSet<Sprint>();
		sprint1 = ObjectFactory.getSprint1();
		sprint2 = ObjectFactory.getSprint2();
		sprint3 = ObjectFactory.getSprint3();
		sprint4 = ObjectFactory.getSprint4();
		sprint5 = ObjectFactory.getSprint5();
		sprint6 = ObjectFactory.getSprint6();
		sprint1.getStories().addAll(storiesOfSprint1);
		sprint2.getStories().addAll(storiesOfSprint2);
		sprint3.getStories().addAll(storiesOfSprint3);
		sprint4.getStories().addAll(storiesOfSprint4);
		sprint5.getStories().addAll(storiesOfSprint5);
		sprint6.getStories().addAll(storiesOfSprint6);
		sprints.add(sprint1);
		sprints.add(sprint2);
		sprints.add(sprint3);
		sprints.add(sprint4);
		sprints.add(sprint5);
		sprints.add(sprint6);
	}

	public static User getCurrentUser() {
		return ObjectFactory.getCurrentUser();
	}

	public Set<Story> getBacklog() {
		Set<Story> backlog = new HashSet<Story>();
		Story story13 = ObjectFactory.getStory13();
		Story story14 = ObjectFactory.getStory14();
		Story story15 = ObjectFactory.getStory15();
		Story story16 = ObjectFactory.getStory16();
		Story story17 = ObjectFactory.getStory17();
		Story story18 = ObjectFactory.getStory18();
		story13.addTasks(ObjectFactory.getTask13_1(),
				ObjectFactory.getTask13_2(), ObjectFactory.getTask13_3());
		story14.addTasks(ObjectFactory.getTask14_1(),
				ObjectFactory.getTask14_2(), ObjectFactory.getTask14_3());
		story15.addTasks(ObjectFactory.getTask15_1(),
				ObjectFactory.getTask15_2(), ObjectFactory.getTask15_3());
		story16.addTasks(ObjectFactory.getTask16_1(),
				ObjectFactory.getTask16_2(), ObjectFactory.getTask16_3());
		story17.addTasks(ObjectFactory.getTask17_1(),
				ObjectFactory.getTask17_2(), ObjectFactory.getTask17_3());
		story18.addTasks(ObjectFactory.getTask18_1(),
				ObjectFactory.getTask18_2(), ObjectFactory.getTask18_3());
		backlog.add(story13);
		backlog.add(story14);
		backlog.add(story15);
		backlog.add(story16);
		backlog.add(story17);
		backlog.add(story18);
		return backlog;
	}

	public Set<Sprint> getSprints() {
		return sprints;
	}

	public Sprint getCurrentSprint() {
		return sprint5;
	}

	public Set<Story> getStoriesOfSprint1() {
		return storiesOfSprint1;
	}

	public Set<Story> getStoriesOfSprint2() {
		return storiesOfSprint2;
	}

	public Set<Story> getStoriesOfSprint3() {
		return storiesOfSprint3;
	}

	public Set<Story> getStoriesOfSprint4() {
		return storiesOfSprint4;
	}

	public Set<Story> getStoriesOfSprint5() {
		return storiesOfSprint5;
	}

	public Set<Story> getStoriesOfSprint6() {
		return storiesOfSprint6;
	}
}